package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"html/template"
	"mydemo/routers"
	"time"
)

func UnixToTime(timestamp int) string {
	t := time.Unix(int64(timestamp), 0)
	return t.Format("2006-01-02 15:04:05")
}
func initMiddleware(c *gin.Context) {
	start := time.Now().UnixNano()
	fmt.Println("1-我是一个中间件")
	c.Next()
	fmt.Println("2-我是一个中间件")
	end := time.Now().UnixNano()
	fmt.Println(end - start)
}
func main() {
	r := gin.Default()
	r.SetFuncMap(template.FuncMap{
		"UnixToTIme": UnixToTime,
	})
	//r.LoadHTMLGlob("templates/**/*")
	//r.Static("/static", "./static")

	routers.AdminRoutersInit(r)
	routers.ApiRoutersInit(r)
	routers.DefaultRoutersInit(r)

	r.Run("localhost:8080")
}
